val input = TextIO.openIn("input.txt");

fun printInt (a:int) =
    print(Int.toString(a)^" ");

fun getInt () =
    Option.valOf (TextIO.scanStream (Int.scan StringCvt.DEC) input);
    
fun printIntList ( [] ) = ()
  | printIntList ( x::xs ) = 
    let
	val tmp = printInt(x)
    in
	printIntList(xs)
    end;

fun getIntList ( 0 ) = []
  | getIntList ( N:int) = getInt()::getIntList(N-1);

(*  完成Begin和End间代码 *)    
(*****Begin*****)
fun reverse([]) = []
    |reverse(a::L) = reverse(L) @ [a]

fun reverse2(L) = 
    let
        fun revHelper([], ret) = ret
            |revHelper(p::params, ret) = revHelper(params, p::ret)
    in
        revHelper(L, [])
    end;


(*****End*****)

val R = getIntList(5);
printIntList (reverse R);
printIntList (reverse2 R); 